package com.xl.rentkeeper.db.orm.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class TypeBuilder {

    public static final Map<Class<?>, String> TYPES = new HashMap<Class<?>, String>();
    static {
        TYPES.put(byte.class, "INTEGER");
        TYPES.put(boolean.class, "INTEGER");
        TYPES.put(short.class, "INTEGER");
        TYPES.put(int.class, "INTEGER");
        TYPES.put(long.class, "INTEGER");
        TYPES.put(float.class, "REAL");
        TYPES.put(double.class, "REAL");

        TYPES.put(Boolean.class, "INTEGER");
        TYPES.put(Integer.class, "INTEGER");
        TYPES.put(Long.class, "INTEGER");
        TYPES.put(Byte.class, "INTEGER");
        TYPES.put(Short.class, "INTEGER");

        TYPES.put(Float.class, "REAL");
        TYPES.put(Double.class, "REAL");

        TYPES.put(byte[].class, "BLOB");
        TYPES.put(String.class, "TEXT");
        TYPES.put(Character.TYPE, "TEXT");

        TYPES.put(Date.class, "INTEGER NULL");
        TYPES.put(java.sql.Date.class, "INTEGER NULL");
        TYPES.put(java.util.Calendar.class, "INTEGER NULL");

    }

    public static String getColumnType(Class<?> type) {
        if (TYPES.containsKey(type)) {
            return TYPES.get(type);
        }
        return "";
    }

}
